package org.example.struct.array2;

/**
 * @author liyishan
 * @date 2024/9/23 10:19
 * @apiNote
 */

public class Test01014MaxScoreSightseeingPair {
    public static void main(String[] args) {
        int[] values = {8,1,5,2,6};
        int res = maxScoreSightseeingPair(values);
        System.out.println(res);
    }
    public static int maxScoreSightseeingPair(int[] values) {
        int ans = 0, max = values[0]+0;
        for(int j =1 ; j< values.length;j++){
            ans = Math.max(ans,max+values[j]-j);
            max = Math.max(max,values[j]+j);
        }
        return ans;
    }
}
